<?php
/*
	插件概览
*/

defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$merchid=$this->checklogin();
$return['printerid']=pdo_getall('jy_weishop_printer',array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid),array('id','title'),'id');
$return['type']=array('1'=>'进云物联58打印机','2'=>'进云物联58打印机NEW','3'=>'进云物联80打印机');	
$return['type'][7]='飞蛾80打印机';
$return['type'][9]='飞蛾58打印机';
$return['type'][8]='芯烨58打印机';
$return['type'][10]='芯烨80打印机';
$return['print_type']=array('1'=>'下单后打印','2'=>'付款后打印','3'=>'确认收货后打印','4'=>'收银结账单','5'=>'收银付款小票','7'=>'退商品小票','8'=>'当日经营打印','9'=>'送商品小票','10'=>'加商品小票','11'=>'签到就诊','12'=>'预约下单小票');
$return['status']=array('0'=>'关闭','1'=>'开启');
$return['duo']=array('1'=>'打印','0'=>'不打印');
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 30;
	$params=array('uniacid'=>$_SESSION['uniacid'],'merchid'=>$merchid);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_weishop_printer_log',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	$htmls=array(
			'type'=>'list',
			'tabs'=>array(
				array('op'=>'list','title'=>'打印日志'),
			),
			'list'=>array('data'=>'list','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
				array('name'=>'type','title'=>'关联打印机类型','type'=>'radio','options'=>'type'),
				array('name'=>'printerid','title'=>'打印机任务','type'=>'select','options'=>'printerid'),
				array('name'=>'print_type','title'=>'订单打印时机','type'=>'radio','options'=>'print_type'),
				array('type'=>'radio','title'=>'打印模式','name'=>'tpl_type','options'=>'tpl_type'),
				array('name'=>'print_nums','title'=>'打印联数','type'=>'string'),
			),'action'=>array(
				array('type'=>'modal','op'=>'detail','title'=>'打印内容'),
			),
		),
	);
	$return['htmls']=$htmls;
	$return['goodstype']=array('全商品打印','按商品分类打印','指定商品打印');
	$return['tpl_type']=array('常规全单打印','单商品打印','单商品小标签打印','单商品大标签打印');
	exi($return);
}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	if(!$id){
		exi('请先选择日志！','error');
	}
	$item=pdo_get('jy_weishop_printer_log',array('id'=>$id,'uniacid'=>$_SESSION['uniacid']));
	$return['item']=$item;
	$return['htmls']=array(
		'type'=>'look',
		'look'=>array(
			array('type'=>'text','name'=>'content','title'=>'打印内容'),
		),
	);
	exi($return);
}